package com.alogic.matcher.impl;

import com.alogic.matcher.CommonMatcher;
import com.anysoft.util.Properties;
import com.google.re2j.Pattern;

/**
 * 基于google的RE2的实现
 *
 * @since 1.6.12.57 [20200103]
 */
public class Re2 implements CommonMatcher {

    /**
     * 正则表达式pattern
     */
    protected Pattern pattern = null;

    public Re2(String regex, Properties p){
        pattern = Pattern.compile(regex);
    }

    @Override
    public boolean isMatch(String data) {
        return pattern != null?pattern.matches(data):false;
    }
}
